import NProgress from 'nprogress'
import 'nprogress/nprogress.css'

import { createRouter, createWebHashHistory } from 'vue-router'

const routes = [
    {
        path: '/index',
        name: '首页',
        component: () => import('../views/index'),
        redirect: 'home',
        children: [
            {
                path: '/home',
                name: '首页',
                component: () => import('../views/layout/home'),
            },
            {
                path: '/staff',
                name: '人员信息',
                component: () => import('../views/page/staff'),
            },
            {
                path: '/mechanism',
                name: '机构信息',
                component: () => import('../views/page/mechanism'),
            },
            {
                path: '/assetsType',
                name: '资产类别管理',
                component: () => import('../views/page/assetsType'),
            },
            {
                path: '/assetsStatus',
                name: '状态管理',
                component: () => import('../views/page/assets/status'),
            },
            {
                path: '/assetsEnroll',
                name: '资产设备登记',
                component: () => import('../views/page/assets/enroll'),
            },
            {
                path: '/assetsIndex',
                name: '基本信息展示',
                component: () => import('../views/page/assets/index'),
            },
            {
                path: '/assetsInout',
                name: '调拨信息展示',
                component: () => import('../views/page/assetsInout/index'),
            },
            {
                path: '/assetsFixIndex',
                name: '维修信息展示',
                component: () => import('../views/page/assetsFix/index'),
            },
            {
                path: '/assetsDep',
                name: '设备折旧管理',
                component: () => import('../views/page/assetsDep/index'),
            },
            {
                path: '/assetsCheck',
                name: '资产设备统计',
                component: () => import('../views/page/assetCheck/index'),
            },
            {
                path: '/modifyPassword',
                name: '修改密码',
                component: () => import('../views/page/setting/modifyPassword'),
            },
        ]
    },
    {
        path: '/login',
        name: 'login',
        component: () => import('../views/login')
    },
]

const router = createRouter({
    history: createWebHashHistory(),
    routes
})

router.beforeEach((to, from, next) => {
    NProgress.start() // 显示进度条
    next()
})

router.afterEach(() => {
    NProgress.done() // 完成进度条
})

export default router
